/*
/*
 * SimpleEditorTextArea.java
 * Copyright (C) 04/19/2006, 11:47 Francisco J. Hernández
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * 
 */


package SimpleComponents;

import java.awt.Event;
import java.awt.event.KeyEvent;
import java.util.HashMap;
import javax.swing.Action;
import javax.swing.JTextArea;
import javax.swing.KeyStroke;
import javax.swing.text.DefaultEditorKit;
import javax.swing.text.Keymap;

/**
 *
 * @author  Administrador
 */
public class SimpleEditorTextArea extends JTextArea {
    private static HashMap acciones = new HashMap();
    
    /** Creates new form BeanForm */
    public SimpleEditorTextArea() {        
        initComponents();        
        Action []a = this.getActions();
        Keymap keymap = this.addKeymap(null, this.getKeymap());
        for (int i=0; i < a.length; i++)
            acciones.put(a[i].getValue(Action.NAME), a[i]);
        
        // a�ade opcion de copia
        Action tmp = (Action)acciones.get(DefaultEditorKit.copyAction);
        KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK);
        keymap.addActionForKeyStroke(key, tmp);
        tmp.putValue(tmp.NAME, new String(java.util.ResourceBundle.getBundle("SimpleComponents/Bundle").getString("TEXT_COPY")));
        tmp.putValue(tmp.ACCELERATOR_KEY, key);
        editPopupMenu.add(tmp);
        
        // a�ade opcion de cortado
        tmp = (Action)acciones.get(DefaultEditorKit.cutAction);
        key = KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK);
        keymap.addActionForKeyStroke(key, tmp);
        tmp.putValue(tmp.ACCELERATOR_KEY, key);        
        tmp.putValue(tmp.NAME, new String(java.util.ResourceBundle.getBundle("SimpleComponents/Bundle").getString("TEXT_CUT")));
        editPopupMenu.add(tmp);
        
        // a�ade opcion de pegado
        tmp = (Action)acciones.get(DefaultEditorKit.pasteAction);
        key = KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK);
        keymap.addActionForKeyStroke(key, tmp);
        tmp.putValue(tmp.NAME, new String(java.util.ResourceBundle.getBundle("SimpleComponents/Bundle").getString("TEXT_PASTE")));
        tmp.putValue(tmp.ACCELERATOR_KEY, key);
        editPopupMenu.add(tmp);
        
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        editPopupMenu = new javax.swing.JPopupMenu();

        setComponentPopupMenu(editPopupMenu);
    }// </editor-fold>//GEN-END:initComponents
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPopupMenu editPopupMenu;
    // End of variables declaration//GEN-END:variables
    
}
